// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) KALEIDOS INC

// TODO: When button replace remove this @use
@use "ds/_utils.scss" as *;
@use "ds/_sizes.scss" as *;
@use "ds/_borders.scss" as *;
@use "ds/typography.scss" as t;
@use "ds/spacing.scss" as *;
@use "ds/mixins.scss" as *;
@use "refactor/common-refactor.scss" as deprecated;
@use "../../../sidebar/common/sidebar.scss" as sidebar;

.element-set {
  @include sidebar.option-grid-structure;
}

.element-title {
  grid-column: span 8;
}

.title-spacing-layout {
  padding-inline-start: var(--sp-xxs);
  margin: 0;
}

.title-actions {
  position: relative;
  display: flex;
  gap: var(--sp-xs);
  block-size: $sz-32;
  padding: 0;
  margin: 0;
}

.layout-option {
  white-space: nowrap;
}

.flex-layout-menu {
  @include sidebar.option-grid-structure;
  margin-block-end: var(--sp-s);
}

.first-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  margin-block-end: var(--sp-m);
  margin-block-start: var(--sp-xs);
}

.align-row {
  grid-column: span 3;
}

.direction-row-flex {
  grid-column: span 4;
}

// TODO: Replace this buttons with DS buttons
.wrap-button {
  @extend .button-tertiary;
  border-radius: $br-8;
  block-size: $sz-32;
  inline-size: $sz-32;
  svg {
    @extend .button-icon;
    stroke: var(--color-foreground-secondary);
  }
  &.selected {
    @extend .button-icon-selected;
  }
}

.second-row,
.third-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  margin-block-end: var(--sp-m);
}

.align-content-row,
.justify-content-row {
  grid-column: span 6;
}

.forth-row {
  display: grid;
  grid-template-columns:
    var(--grid-exception-input-width) /* first input block */
    var(--grid-exception-input-width) /* second input block */
    var(--sp-xxxl); /* action button */
  gap: var(--sp-xs);
  grid-column: 1 / -1;
}

.help-button-wrapper {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

.gap-group {
  grid-column: span 3;
  display: grid;
  grid-template-columns: subgrid;
}

// TODO: Remove when activating token numeric inputs
.column-gap,
.row-gap {
  @extend .input-element;
  @include t.use-typography("body-small");
  &.disabled {
    @extend .disabled-input;
  }
}

// TODO: Remove when activating token numeric inputs
.padding-simple,
.padding-multiple {
  @include t.use-typography("body-small");
  @extend .input-element;
}

.padding-group {
  display: grid;
  grid-column: span 3;
  grid-template-columns: subgrid;
}

.padding-inputs,
.paddings-simple {
  grid-column: span 2;
  display: grid;
  grid-template-columns: subgrid;
}

.paddings-multiple {
  display: grid;
  grid-column: span 2;
  grid-template-columns: subgrid;
  gap: var(--sp-xs);
}

// TODO: Replace this buttons with DS buttons
.padding-toggle {
  @extend .button-tertiary;
  block-size: $sz-32;
  inline-size: $sz-32;
  border-radius: $br-8;
  svg {
    @extend .button-icon;
    stroke: var(--color-foreground-secondary);
  }
  &.selected {
    @extend .button-icon-selected;
  }
}

.grid-layout-menu {
  @include sidebar.option-grid-structure;
}

.edit-grid-wrapper,
.first-row,
.grid-layout-align,
.gap-row,
.padding-row {
  grid-column: 1 / -1;
}

.first-row {
  margin-block-end: var(--sp-s);
  display: grid;
  grid-template-columns: subgrid;
}

.grid-layout-align {
  display: grid;
  grid-template-columns: subgrid;
  align-items: flex-start;
  position: relative;
  gap: var(--sp-xs);
}

.locate-button {
  grid-row: 1;
  grid-column: 8;
}

.grid-layout-menu-title {
  @include t.use-typography("headline-small");
  flex: 1;
  color: var(--color-foreground-primary);
  grid-column: span 5;
}

// TODO: Replace this buttons with DS buttons
.edit-mode-btn {
  @extend .button-secondary;
  @include t.use-typography("headline-small");
  inline-size: 100%;
  padding: var(--sp-s);
  grid-column: span 7;
}

// TODO: Replace this buttons with DS buttons
.exit-btn {
  @extend .button-secondary;
  @include t.use-typography("headline-small");
  padding: var(--sp-s) var(--sp-xl);
  grid-column: span 2;
}

.grid-tracks-info-container {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  gap: var(--sp-xs);
  margin-block-start: var(--sp-xs);
}

.padding-section {
  margin-block-start: var(--sp-s);
}

.grid-tracks-row {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
}

.edit-grid-wrapper {
  display: grid;
  grid-template-columns: subgrid;
}

.track-info {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;

  &.dnd-over-top {
    border-block-start: $b-2 solid var(--color-accent-primary);
  }

  &.dnd-over-bot {
    border-block-end: $b-2 solid var(--color-accent-primary);
  }
}

.track-info-container {
  display: flex;
  grid-column: 1 / span 7;
}

// TODO: Replace this buttons with DS buttons
.track-info-dir-icon {
  cursor: pointer;
  border-radius: $br-8 0 0 $br-8;
  background-color: var(--color-background-tertiary);
  padding: 0 var(--sp-s);
  svg {
    @extend .button-icon;
    stroke: var(--color-foreground-secondary);
    block-size: 100%;
  }
  &:hover svg {
    stroke: var(--color-foreground-primary);
  }
}

.track-info-value {
  @extend .input-element;
  @include t.use-typography("body-small");
  border-radius: 0;
  border-inline-end: $b-1 solid var(--color-background-primary);
}

.track-info-unit-selector {
  border-radius: 0 $br-8 $br-8 0;
  inline-size: px2rem(96);
}

.grid-tracks {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  margin-block-start: var(--sp-s);
}

.grid-track-header {
  @include t.use-typography("body-small");
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  border-radius: $br-8;
  overflow: hidden;
  background: var(--color-background-tertiary);
  block-size: px2rem(52);
  grid-column: 1 / -1;
}

.track-title {
  display: grid;
  flex-grow: 1;
  padding: var(--sp-s);
  gap: 0;
  overflow: hidden;
}

.track-name {
  color: var(--color-foreground-primary);
}

.track-detail {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  inline-size: 100%;
  color: var(--color-foreground-secondary);
}

// TODO: Replace this buttons with DS buttons
.expand-icon {
  @extend .button-secondary;
  block-size: px2rem(52);

  border-radius: $br-8 0 0 $br-8;
  border-inline-end: $b-1 solid var(--color-background-primary);
  svg {
    @extend .button-icon;
    stroke: var(--color-foreground-secondary);
    fill: var(--color-foreground-secondary);
  }
  &:hover,
  &:active {
    svg {
      stroke: var(--color-accent-primary);
      fill: var(--color-accent-primary);
    }
  }
}

// TODO: Replace this buttons with DS buttons
.add-column {
  @extend .button-tertiary;
  block-size: px2rem(52);

  svg {
    display: flex;
    justify-content: center;
    align-items: center;
    color: transparent;
    fill: none;
    stroke-width: px2rem(1);
    block-size: $sz-12;
    inline-size: $sz-12;
    stroke: var(--color-foreground-secondary);
    fill: var(--color-foreground-secondary);
  }
}

.layout-options {
  box-shadow: 0px 0px $sz-12 0px var(--color-shadow-dark);
  position: absolute;
  display: flex;
  flex-direction: column;
  inset-block-start: $sz-32;
  inset-inline-start: initial;
  inset-inline-end: var(--sp-s);
  max-block-size: var(--menu-max-height, px2rem(300));
  padding: var(--sp-xxs);
  margin: 0;
  margin-block-start: px2rem(1);
  border-radius: $br-8;
  z-index: var(--z-index-dropdown);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--color-background-tertiary);
  color: var(--color-foreground-primary);
  border: $b-2 solid var(--color-background-quaternary);
  gap: var(--sp-xs);
  inline-size: fit-content;

  button {
    border: none;
    background: none;
    cursor: pointer;
    padding: var(--sp-s);
    color: var(--color-foreground-primary);
    border-radius: $br-6;

    &:hover {
      background: var(--color-background-quaternary);
    }
  }
}

.direction-edit {
  grid-column: span 2;
}

.align-grid-row {
  grid-column: span 3;
}

.justify-grid-row {
  grid-column: 1 / span 6;
}

.gap-row,
.padding-row {
  display: grid;
  grid-template-columns:
    var(--grid-exception-input-width) /* first input block */
    var(--grid-exception-input-width) /* second input block */
    var(--sp-xxxl); /* action button */
  gap: var(--sp-xs);
}

.grid-first-row {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
}

.numeric-input-measures {
  --dropdown-width: var(--7-columns-dropdown-width);
}
